<?php

/**
 * This is the model class for table "view_checkpoint".
 *
 * The followings are the available columns in table 'view_checkpoint':
 * @property string $id
 * @property string $tb_bongkar_muat_id
 * @property string $noTiket
 * @property string $noDokumen
 * @property string $noPolisi
 * @property string $tipe
 * @property string $deskripsi
 * @property string $statusMobil
 * @property integer $gate
 * @property integer $statusParkir
 * @property string $timbanganKeluar
 * @property string $waktuMulai
 * @property string $waktuSelesai
 */
class ViewCheckpoint extends CActiveRecord
{
	public $notes;
        
        public function primaryKey()
	{
	   return 'id';
	}
        /**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'view_checkpoint';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('noDokumen', 'required'),
			array('gate, statusParkir', 'numerical', 'integerOnly'=>true),
			array('id, tb_bongkar_muat_id', 'length', 'max'=>11),
			array('noTiket, noPolisi', 'length', 'max'=>15),
			array('noDokumen, statusMobil', 'length', 'max'=>20),
			array('tipe', 'length', 'max'=>10),
			array('deskripsi', 'length', 'max'=>50),
			array('noTiket, noDokumen, noPolisi, tipe, deskripsi, statusMobil, gate, timbanganMasuk, waktuParkir', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('noTiket, noDokumen, noPolisi, tipe, deskripsi, statusMobil, gate, timbanganMasuk, waktuParkir', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'tb_bongkar_muat_id' => Yii::t('model', 'Bongkar Muat'),
			'noTiket' => Yii::t('model', 'No Tiket'),
			'noDokumen' => Yii::t('model', 'No Dokumen'),
			'noPolisi' => Yii::t('model', 'No Polisi'),
			'tipe' => Yii::t('model', 'Tipe'),
			'deskripsi' => Yii::t('model', 'Deskripsi'),
			'statusMobil' => Yii::t('model', 'Status Mobil'),
			'gate' => Yii::t('model', 'Gate'),
			'statusParkir' => Yii::t('model', 'Status Parkir'),
			'timbanganMasuk' => Yii::t('model', 'Masuk Timbangan'),
			'waktuParkir' => Yii::t('model', 'Masuk Parkir'),
			'notes' => Yii::t('model', ''),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('tb_bongkar_muat_id',$this->tb_bongkar_muat_id,true);
		$criteria->compare('noTiket',$this->noTiket,true);
		$criteria->compare('noDokumen',$this->noDokumen,true);
		$criteria->compare('noPolisi',$this->noPolisi,true);
		$criteria->compare('tipe',$this->tipe,true);
		$criteria->compare('deskripsi',$this->deskripsi,true);
		$criteria->compare('statusMobil',$this->statusMobil,true);
		$criteria->compare('gate',$this->gate);
		$criteria->compare('timbanganMasuk',$this->timbanganMasuk,true);
		$criteria->compare('waktuParkir',$this->waktuParkir,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return ViewCheckpoint the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
